package com.ns002.yigou.quote.common.listeners;

import com.ns002.yigou.quote.common.connection.HuangJinQuoteConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @author xu
 * 容器启动事件
 */
@Component
public class ApplicationStartListener implements ApplicationRunner {

    @Autowired
    HuangJinQuoteConnection huangJinQuoteConnection;

    @Value("${quote.save}")
    private boolean quoteSvae;

    @Override
    public void run(ApplicationArguments args) throws Exception {

        if(!quoteSvae){
            return;
        }

        System.out.println("--------------------------容器启动成功------------------------------");
        System.out.println("启动美元指数抓取...");
        huangJinQuoteConnection.connection();
        System.out.println("美元指数启动完成OK");

    }
}
